package lego.diagram.edit.parts.custom.figure;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.ImageUtilities;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;

public abstract class ComponentFigure extends Shape {

	protected Image mImage;

	public ComponentFigure() {
		this.initFigure();
	}

	protected void initFigure() {
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
				.getShell();
		mImage = new Image(shell.getDisplay(), this.getClass()
				.getResourceAsStream(this.getImagePath()));
	}

	protected abstract String getImagePath();

	@Override
	protected void fillShape(Graphics arg0) {// Do nothing
	}

	@Override
	protected void outlineShape(Graphics graphics) {
		graphics.drawImage(mImage, new Point(this.getBounds().getLocation()));
	}
}